a = input()
s = []
k = 0
k1 = 0
r = 0
r1 = 0
t = 0
t1 = 0
y = 0
y1 = 0
for i in range(len(a)):
    s.append(a[i])
for i in range(len(a)):
    if s[0] == ')' or s[0] == ']' or s[-1] == '(' or s[-1] == '[' or s[0] == '}' or s[0] == '>' or s[-1] == '{' or s[-1] == '<':
        print('False')
        break
    if s[i] == '[':
        r = r + 1
    if s[i] == ']':
        r1 = r1 + 1
    if s[i] == ')':
        k1 = k1 + 1
    if s[i] == '(':
        k = k + 1
    if s[i] == '{':
        t = t + 1
    if s[i] == '}':
        t1 = t1 + 1
    if s[i] == '<':
        y = y + 1
    if s[i] == '>':
        y1 = y1 + 1
    if (s[i - 1] == '[' and s[i] == ')') or (s[i - 1] == '[' and s[i] == '}') or (s[i - 1] == '[' and s[i] == '>'):
        print("False")
        break
    elif (s[i - 1] == '(' and s[i] == ']') or (s[i - 1] == '(' and s[i] == '}') or (s[i - 1] == '(' and s[i] == '>'):
        print("False")
        break
    elif (s[i - 1] == '{' and s[i] == ']') or (s[i - 1] == '{' and s[i] == ')') or (s[i - 1] == '{' and s[i] == '>'):
        print("False")
        break
    elif (s[i - 1] == '<' and s[i] == ']') or (s[i - 1] == '<' and s[i] == '}') or (s[i - 1] == '<' and s[i] == ')'):
        print("False")
        break
    if s[i - 1] == '(' and s[i] == ')':
        print("True")
        break
    elif s[i - 1] == '[' and s[i] == ']':
        print("True")
        break
    elif s[i - 1] == '{' and s[i] == '}':
        print("True")
        break
    elif s[i - 1] == '<' and s[i] == '>':
        print("True")
        break
    if k1 > k or r1 > r or t1 > t or y1 > y:
        print("False")
        break
c = 0
c1 = 0
v = 0
v1 = 0
b = 0
b1= 0
n = 0
n1 = 0
for i in range(len(a)):
    if s[i] == '[':
        c = c + 1
    if s[i] == ']':
        c1 = c1 + 1
    if s[i] == ')':
        v1 = v1 + 1
    if s[i] == '(':
        v = v + 1
    if s[i] == '{':
        b = b + 1
    if s[i] == '}':
        b1 = b1 + 1
    if s[i] == '<':
        n = n + 1
    if s[i] == '>':
        n1 = n1 + 1
if c > c1 or v > v1 or b > b1 or n > n1:
    print("False")